package T31_T40;

import datastructure.TreeNode;
import java.util.ArrayList;
import java.util.List;

public class T36 {

    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> res=new ArrayList<>();
        inorderhelper(root,res);
        return res;
    }
    private static void inorderhelper(TreeNode node,List<Integer> res){
        if (node==null)return;
        inorderhelper(node.left,res);//遍历左子树
        res.add(node.val);//根结点
        inorderhelper(node.right,res);//右子树
    }
}
